<?php


namespace app\model;
use think\Model;

class User extends Model
{
    public function checkUser($data){
        $res = User::where('tel',$data['tel'])->where('password',sha1($data['password']))->find();
        return $res;
    }

    public function register($data){
        if(($data['name'] == null) || ($data['tel'] == null) || ($data['password'] == null)){
            return false;
        }else{
            $tel = User::where('tel',$data['tel'])->find();
            if($tel){
                return false;
            }else{
                if ($data['password'] != sha1($data['confirm'])){
                    return false;
                }else{
                    $res = User::create($data);
                    return $res;
                }

            }
        }
    }

    public function checkTel($tel){
        $res = User::where('tel',$tel)->field('tel')->find();
        if($res){
            return false;
        }else{
            return true;
        }
    }
}